from selenium import webdriver
from selenium.webdriver.common.by import By
from po.page import Page
from po.page2 import Page2
from po.page3 import Page3
from ddt import ddt,file_data
import unittest,time

class Case(unittest.TestCase):
    def setUp(self) -> None:
        print('begin case')
        self.driver=webdriver.Chrome()
        self.driver.maximize_window()
    def tearDown(self) -> None:
        print('end case')
        time.sleep(3)
        self.driver.quit()

    def test_version_001(self):
        po=Page(self.driver)
        po.open_url('http://localhost:8081/')
        time.sleep(2)
        po.list()
        title_loc=(By.XPATH,'/html/body/div/div/section/aside/ul/li/ul/li[13]/a')
        title=po.find_element(title_loc).text
        print(title)
        self.assertEqual(title,'游戏版本管理功能')
        time.sleep(2)
        po.add()
        time.sleep(2)
        po.name()
        time.sleep(1)
        po.data()
        time.sleep(1)
        po.status()
        time.sleep(1)
        po.commit()



    def test_version_002(self):
        po = Page3(self.driver)
        po.open_url('http://localhost:8081/')
        time.sleep(2)
        po.list()
        time.sleep(2)
        title_loc = (By.XPATH, '/html/body/div/div/section/aside/ul/li/ul/li[13]/a')
        title = po.find_element(title_loc).text
        print(title)
        self.assertEqual(title, '游戏版本管理功能')
        time.sleep(2)
        po.name()
        time.sleep(2)
        po.select()

    def test_version_003(self):
        po = Page2(self.driver)
        po.open_url('http://localhost:8081/')
        time.sleep(2)
        po.list()
        title_loc = (By.XPATH, '/html/body/div/div/section/aside/ul/li/ul/li[13]/a')
        title = po.find_element(title_loc).text
        print(title)
        self.assertEqual(title, '游戏版本管理功能')
        time.sleep(2)
        po.delete()


if __name__ == '__main__':
    unittest.main()